<%-- 
    Document   : ChiTietSP
    Created on : Oct 17, 2011, 1:44:37 AM
    Author     : linh
--%>

<%@page import="java.util.ArrayList"%>
<%@page import="MODEL.POJO.ChiTietSanPhamPOJO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>

<script src="js/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('#main_phim4>div').each(function(){
            var $img=$(this).children().attr('src');
            //alert($img)
            var $title=$(this).find('p.name').text()
            //alert($title)
            $(this).find('div.info').prepend('<img src='+$img+' /><p class="title">'+$title+'</p>')
        })
        $('#main_phim4>div>img').hover(function(){
            $(this).parent().find('div.info').show()
        },function(){
            $(this).parent().find('div.info').hide()
        }).mousemove(function(e){
            var $X=e.clientX
            var $Y=e.clientY
            $(this).parent().find('div.info').css({'left':$X+20,'top':$Y})
        }).click(function(){
            var $link=$(this).parent().find('a').attr('href')
            window.open($link,'')
        })
    })
</script>

<%
    String loaisanpham = (String) request.getAttribute("LoaiSanPhams");
    String iddanhmuc = (String) request.getAttribute("IdDanhMuc");
    ChiTietSanPhamPOJO ctsp = (ChiTietSanPhamPOJO) request.getAttribute("ChiTiet");
    int soluongtrang = (Integer) request.getAttribute("SoTrang");
%>
<div class="boxsp">
    <table border="0" align="center" width="500">
        <tr>
        <td width="" colspan="2" align="center"><a title="<%=ctsp.getTensanpham()%>" style="color:#FF0000; font-size:20px;"><strong><span style="color:#0066FF; CURSOR: hand" onMouseOver="this.style.color='#FF0000'; " onMouseOut="this.style.color='#0066FF'; "><%=ctsp.getTensanpham()%></span></strong></a></td>
        </tr>
        <tr>
        <td align="center" colspan="2"><a title="<%=ctsp.getTensanpham()%>" style="color:#FF0000; font-size:16px;"><strong><span style="color:#0066FF; CURSOR: hand" onMouseOver="this.style.color='#FF0000'; " onMouseOut="this.style.color='#0066FF'; "><img src="<%=ctsp.getHinh()%>" width="200px" height="200px"/></span></strong></a></td>
        </tr>
        <tr><td align="center" colspan="3"><span style="color:#FF0000;font: vernada" ><%=ctsp.getGiaban()%> VNĐ</span></td></tr>
        <tr>
        <td><a title="<%=ctsp.getTensanpham()%>" style="color:#FF0000; font-size:16px;"><strong><span style="color:#0066FF; CURSOR: hand" onMouseOver="this.style.color='#FF0000'; " onMouseOut="this.style.color='#0066FF'; ">Lượt xem: <%= ctsp.getSolanxem()%></span></strong></a></td>
        <td>&nbsp;</td>
        </tr>
        <tr>
        <td colspan="2"><strong>Model: </strong><%=ctsp.getIdsanpham()%></td>
        </tr>
        <tr>
        <td colspan="2"><strong>Thông tin: </strong><%=ctsp.getMota()%></td>
        </tr>
        <tr>
        <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
        <td colspan="2"><strong>Bảo hành:</strong> <%=ctsp.getBaohanh()%> Tháng | <strong>Kho hàng: </strong><%=ctsp.getSoluongton()%></td>
        </tr>
        <tr>
        <td colspan="2"><strong>Vận chuyển</strong> To&agrave;n qu&#7889;c</td>
        </tr>
        <tr>
        <td><strong>Khuyến mãi</strong> &nbsp; Mi&#7871;ng d&aacute;n m&agrave;n h&igrave;nh</td>
        <td><div class="muahang"><a href="CartController?Action=ChoVaoGioHang&idloaisanpham=<%=request.getParameter("Action")%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>"><img src="images/dathang1.gif"/></a></div></td>
        </tr>
    </table>
</div>

<hr>


<!--Lay san pham cug loai-->

<div class="tieude1">Sản phẩm cùng loại</div>
<div class="noidung">
    <%
        ArrayList<ChiTietSanPhamPOJO> sanphamcungloai = (ArrayList<ChiTietSanPhamPOJO>) request.getAttribute("SanPhamCungLoai");
        for (int j = 0; j < sanphamcungloai.size(); j++) {
            ChiTietSanPhamPOJO spcungloai = sanphamcungloai.get(j);
    %>
    <div class="box">
        <div class="name"><a href="ChiTietController?Action=<%=loaisanpham%>&idchitietsanpham=<%=spcungloai.getIdchitietsanpham()%>&iddanhmuc=<%= iddanhmuc%>"><strong><span style="color:#0066FF; CURSOR: hand" onMouseOver="this.style.color='#FF0000'; " onMouseOut="this.style.color='#0066FF'; "><%=spcungloai.getTensanpham()%></span></strong></div>
        <div class="hinh"><a href="ChiTietController?Action=<%=loaisanpham%>&idchitietsanpham=<%=spcungloai.getIdchitietsanpham()%>"><img src="<%=spcungloai.getHinh()%>" width="100px" height="100px"/></a></div>
        <div class="gia">Giá:<%= spcungloai.getGiaban()%> VNĐ</div>
    </div>

    <%  }%>
</div>
<div>
    <%
        int trangtruoc = 1;
        int tranghienhanh=1;
        if (request.getParameter("Trang") != null) {
            tranghienhanh = Integer.parseInt(request.getParameter("Trang"));
            if (tranghienhanh > 1) {
                trangtruoc = tranghienhanh - 1;
            }
        }
        if (soluongtrang > 1) {
    %>
    <a  href="ChiTietController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&Trang=<%=trangtruoc%>">[Trang trước]</a>Trang: 
    <%  for (int i = 1; i <= soluongtrang; i++) {%>
    <a href="ChiTietController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&Trang=<%=i%>"><%=i%><a/>
        <% }
            int trangsau = trangtruoc + 1;
            if (request.getParameter("Trang") != null) {
                tranghienhanh = Integer.parseInt(request.getParameter("Trang"));
                if (trangsau < soluongtrang) {
                    trangsau = tranghienhanh + 1;
                }
            }%>
        <a  href="ChiTietController?Action=<%=loaisanpham%>&idchitietsanpham=<%=ctsp.getIdchitietsanpham()%>&Trang=<%=trangsau%>">[Trang sau]</a>
        <%}%>
</div>
